package main

import "fmt"

func Print[T any](arr []T) {
	for _, v := range arr {
		fmt.Print(v)
		fmt.Print(" ")
	}
	fmt.Println("")
}

type WowStruct[T int | float32, S []T] struct {
	Data     S
	MaxValue T
	MinValue T
}

func main() {
	strs := []string{"Hello", "World", "Generics"}
	decs := []float64{3.14, 1.14, 1.618, 2.718}
	nums := []int{2, 4, 6, 8}
	// 错误，类型形参不能单独使用
	type Wow[T int | string] int

	var a Wow[int] = 123        // 编译正确
	var b Wow[string] = 123     // 编译正确
	var c Wow[string] = "hello" // 编译错误，因为"hello"不能赋值给底层类型int
	Print(strs)
	Print(decs)
	Print(nums)
}
